﻿#pragma once

#include "Render/VulkanMemory/MemoryPool.h"

class CVulkanImage
{

public:

    CVulkanImage()=default;
    ~CVulkanImage();



    void SetImageParams(
        const vk::ImageCreateInfo& InImageCreateInfo
    );

    void SetDepthImageParams(
        uint32_t InWidth
        , uint32_t InHeight
    );

    //创建/重新创建一个2d纹理图像
    void SetTexture2DImageParams(
        uint32_t InWidth
        , uint32_t InHeight
        , vk::Format InFormat
    );

    //刷新缓冲区内容,在SetImageParams之后调用
    void WriteData(
        const uint8_t* InImagePixelData
        , uint64_t InPixelDataSize
        , uint32_t InPitch
    );

    vk::Image GetImage() const { return Image; }

    vk::Extent2D GetImageSize() const
    {
        return vk::Extent2D( ImageCreateInfo.extent.width, ImageCreateInfo.extent.height );
    }

    vk::Format GetFormat() const { return ImageCreateInfo.format; }
protected:
    void BindMemory(
        vk::Image InImage
    );

    vk::Image Image=nullptr;
    SVulkanMemoryBlock MemoryBlock;

    // uint32_t Width=0;
    // uint32_t Height=0;
    // vk::Format Format=vk::Format::eUndefined;
    // vk::ImageUsageFlags Usage=vk::ImageUsageFlagBits::eSampled;
    // vk::ImageLayout InitialLayout = vk::ImageLayout::ePreinitialized;

    vk::ImageCreateInfo ImageCreateInfo;
};